import { _decorator, instantiate, Node, Prefab } from "cc";
import { BaseSceneManager } from "./base-scene-manager";
import { ItemType } from "../model";
import { BackPackManager } from "../back-pack-manager";
const { ccclass, property } = _decorator;

@ccclass("H4SceneManager")
export class H4SceneManager extends BaseSceneManager {
  @property(Node)
  mailPlaceholder: Node = null;

  @property(Prefab)
  mailPrebab: Prefab = null;

  render(): void {
    super.render();

    this.items.removeAllChildren();
    const isMailInScene = BackPackManager.Instance.isItemInScene(ItemType.Mail);
    if (isMailInScene) {
      const mail = instantiate(this.mailPrebab);
      this.items.addChild(mail);
      mail.setPosition(this.mailPlaceholder.position);
    }
  }
}
